package com.housekeeperapp.services;

import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;

import androidx.annotation.Nullable;

import com.housekeeperapp.R;

/**
 * Created by xiaolong.wei on 2018/7/31.
 */

public class ForegroundService extends Service {
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Notification.Builder notificationBuilder = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            notificationBuilder = new Notification.Builder(this, "消息通知");
        }else{
            notificationBuilder = new Notification.Builder(this);
        }
        notificationBuilder.setSmallIcon(R.drawable.icon_launcher2);
        notificationBuilder.setWhen(System.currentTimeMillis());
        notificationBuilder.setContentTitle("管家来了");
        notificationBuilder.setContentText("管家来了消息服务");
        Notification notification = notificationBuilder.build();
        startForeground(1,notification);
    }
}
